//package com.kmvc.vcbase.aop;
//
//import com.kmvc.vcbase.anno.SpecifyDataSource;
//import com.kmvc.vcbase.config.DynamicDataSource;
//import com.kmvc.vcbase.em.DataSourceTypeEnum;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.lang.reflect.Method;
//
///**
// * vcbase
// *
// * @author 95634
// * @描述
// * @date 2023/3/6 10:06
// **/
////@Aspect
////@Component
////@Order(value = 1)
//public class DataSourceAspect {
//    private Logger logger = LoggerFactory.getLogger(this.getClass());
//
//    @Pointcut("@annotation(com.kmvc.vcbase.anno.SpecifyDataSource)")
//    public void dataSourcePointCut() {
//
//    }
//
//    @Around("dataSourcePointCut()")
//    public Object around(ProceedingJoinPoint point) throws Throwable {
//        MethodSignature signature = (MethodSignature) point.getSignature();
//        Method method = signature.getMethod();
//
//        SpecifyDataSource ds = method.getAnnotation(SpecifyDataSource.class);
//        if (ds == null) {
//            DynamicDataSource.setDataSource(DataSourceTypeEnum.BASE_DB.getName());
//            logger.info("set datasource is " + DataSourceTypeEnum.BASE_DB);
//        } else {
//            DynamicDataSource.setDataSource(ds.value().getName());
//            logger.info("set datasource is " + ds.value().getName());
//        }
//
//        try {
//            return point.proceed();
//        } finally {
//            DynamicDataSource.clearDataSource();
//            logger.info("clean datasource");
//        }
//    }
//}
